package com.example.onlineeducation.data.constant

import androidx.annotation.DrawableRes
import androidx.annotation.StringDef
import com.example.onlineeducation.R

/**
 * SimpleDes:
 * Creator: Sindi
 * Date: 2022-01-17
 * UseDes:问题类型
 */
object QuestionType {
    const val SINGLE = "01"//单选
    const val MULTIPLE = "02"//多选
    const val JUDGE = "03"//判断

    @StringDef(MULTIPLE, SINGLE, JUDGE)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class Type

    fun showQuestionTypeText(@Type str: String?): String {
        return when (str) {
            SINGLE -> "单选题"
            MULTIPLE -> "多选题"
            JUDGE -> "判断题"
            else -> "-"
        }
    }

    /*
    * 回答结果：0-答错,1-答对
    * */
    const val IS_ERROR = "0"//答错
    const val IS_RIGHT = "1"//答对

    @StringDef(IS_RIGHT, IS_ERROR)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class AnswerResult

    @DrawableRes
    fun showAnswerResultIcon(@AnswerResult str: String?): Int {
        return when (str) {
            IS_RIGHT -> R.drawable.ic_result_right
            else -> R.drawable.ic_result_wrong
        }
    }

}